package cn.wenxin_zhang.smart4j.plus.proxy;

import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * Created by Wenxin on 2017/3/8.
 */
public class MapperManager {

    public static <T> T createMapperProxy(Class<T> cls){

        return (T)Enhancer.create(cls, new MethodInterceptor() {
            @Override
            public Object intercept(Object obj, Method method, Object[] params, MethodProxy methodProxy) throws Throwable {
                return new MapperProxy(obj,cls,method,params,methodProxy).doProxy(null);
            }
        });
    }
}
